package com.dream.cgomall.controller;

import com.dream.cgomall.entity.CgoGoodEvaluate;
import com.dream.cgomall.entity.CgoGoodPicture;
import com.dream.cgomall.entity.CgoGoods;
import com.dream.cgomall.entity.CgoGuarantee;
import com.dream.cgomall.service.CgoGoodEvaluateService;
import com.dream.cgomall.service.CgoGoodsService;
import com.dream.cgomall.service.impl.CgoGoodGuaranteeServiceImpl;
import com.dream.cgomall.service.impl.CgoGoodsPictureImpl;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/goods")
public class CgoGoodsController {
    @Autowired
    CgoGoodsService cgoGoodsService;
    @Autowired
    CgoGoodsPictureImpl cgoGoodsPicture;
    @Autowired
    CgoGoodGuaranteeServiceImpl cgoGoodGuaranteeService;
    @Autowired
    CgoGoodEvaluateService cgoGoodEvaluateService;

    @RequestMapping("/good/{id}")
    public CgoGoods goods(@PathVariable("id") Integer id) {
        CgoGoods c = cgoGoodsService.findGoods(id);
        System.out.println(c.getSendSpend());
        return c;
    }

    @RequestMapping("/picture/{id}")
    public Map<String, List<CgoGoodPicture>> picture(@PathVariable("id") Integer id) {
        return cgoGoodsPicture.cgoGoodPicture(id);
  
    }

    @RequestMapping("/gura/{id}")
    public List<CgoGuarantee> gura(@PathVariable("id") Integer id) {
        return cgoGoodGuaranteeService.findGuar(id);
    }

    @RequestMapping("/evacount/{id}")
    public Integer count(@PathVariable("id") Integer id) {
        return cgoGoodEvaluateService.findEvaCount(id);
    }
    @RequestMapping("/eva/{id}")
    public List<CgoGoodEvaluate> eval(@PathVariable("id")Integer id){
        return cgoGoodEvaluateService.findEvalById(id);
    }

}
